package com.iss.springdemo1.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AspectAdvice {
    @Pointcut("execution(* com.iss.springdemo1.aop.*.*(..))")
    /*   @Pointcut("bean(*Class)")*/
    public void   anyMethod(){
   }

  @Before(value="anyMethod()")
   public void  doBefore(JoinPoint jp){

       Object target = jp.getTarget();
       System.out.println("class:"+target.getClass());
       System.out.println(jp.getSignature().getName());
       System.out.println("****** start *********");
   }
    /*
    @After(value="anyMethod()")
    public void  doAfter(JoinPoint jp){
        System.out.println("****** end *********");
    } */

    @AfterThrowing(value="anyMethod()")
    public  void doException(JoinPoint jp){
       //报错时候触发
        System.out.println("报错了！");
    }

  /*  @AfterReturning(value = "anyMethod()")
    public  void doReturn(JoinPoint jp){

        System.out.println("return xxxx");
    }*/


  /* @Around(value = "anyMethod()")
    public  void doRound(JoinPoint jp){
       System.out.println("around");
    }*/
}
